package com.butterfly.domain.dao;

import com.butterfly.domain.entity.MerchantAd;
import org.hibernate.Criteria;

import javax.inject.Named;
import java.util.List;


@Named
public class MerchantAdDAOImpl extends AbstractDaoHibernate<MerchantAd> implements MerchantAdDAO {
    @Override
    protected Class<MerchantAd> getEntityClass() {
        return MerchantAd.class;
    }

    @Override
    public List<MerchantAd> getMerchantAdList(int firstResult, int maxResult) {
        Criteria criteria = getSession().createCriteria(MerchantAd.class);

        if (maxResult > 0) {
            return criteria.setFirstResult(firstResult).setMaxResults(maxResult).list();
        }
        return criteria.list();
    }
}
